<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2016/10/10
 * Time: 14:28
 */

require_once 'HttpClient.php';
//GET请求
$http = new HttpClient();
$http->set_header('User-Agent','Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1');
$http->get('http://wp4.6.dev/?json=get_post&post_id=5');
echo $http->get_body();
//POST请求
//
//$http = new HttpClient();
//$http->set_header('User-Agent','Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1');
//$data = array(
//    'id'=>1,
//    'name'=>'example'
//);
//$file = array(
//    'photo'=>'/data/patch/file.jpg'
//);
//$http->post('http://www.example.com/',array($data)[,$file]);
//echo $http->get_body();
//Cookie支持
//
//$http->set_cookies($cookie);
//代理支持
//
//$http->set_proxy('socks5.example.com:1080',HttpClient::PROXY_SOCKS5,'user','password');
//



//require_once 'HTTP/Client.php';
//$http = new HTTP_Client();
//$http->get('http://wordpress.test/?json=core.get_author_index&dev=1');
//$response = $http->currentResponse();
//$response = json_decode($response['body']);
//$author = $response->authors[0];
//
//echo "Response status: $response->status\n";
//echo "Author count: $response->count\n";
//echo "Author name: $author->name\n";
//echo 'begin..';
//$curl = curl_init();
//curl_setopt($curl, CURLOPT_URL, "http://wp4.6.dev/?json=get_post&post_id=5");
//curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($curl, CURLOPT_HEADER, 0);
//curl_exec($curl);
//curl_close($curl);
//var_dump($curl);